# This pipeline only runs on GitHub PRs, not on merges.
trigger: none

# Only run on changes to the JIT directory. Don't run if the JIT-EE GUID has changed,
# since there won't be any SuperPMI collections with the new GUID until the collection
# pipeline completes after this PR is merged.
pr:
  branches:
    include:
    - main
  paths:
    include:
    - src/coreclr/jit/*
    - src/coreclr/tools/superpmi/*
    exclude:
    - src/coreclr/inc/jiteeversionguid.h

variables:
  - template: /eng/pipelines/common/variables.yml

extends:
  template:  /eng/pipelines/common/templates/pipeline-with-resources.yml
  parameters:
    stages:
    # Don't run if the JIT-EE GUID has changed,
    # since there won't be any SuperPMI collections with the new GUID until the collection
    # pipeline completes after this PR is merged.
    - ${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
      - stage: EvaluatePaths
        displayName: Evaluate Paths
        jobs:
        - template: /eng/pipelines/common/evaluate-paths-job.yml
          parameters:
            paths:
            - subset: jiteeversionguid
              include:
              - src/coreclr/inc/jiteeversionguid.h

    - stage: Build
      jobs:

      - template: /eng/pipelines/common/platform-matrix.yml
        parameters:
          jobTemplate: /eng/pipelines/common/global-build-job.yml
          buildConfig: checked
          platforms:
          - windows_x64
          - windows_x86
          jobParameters:
            buildArgs: -s clr.alljits+clr.spmi -c $(_BuildConfig)
            postBuildSteps:
              - template: /eng/pipelines/common/upload-artifact-step.yml
                parameters:
                  rootFolder: $(Build.SourcesDirectory)/artifacts/bin/coreclr
                  includeRootFolder: false
                  archiveType: $(archiveType)
                  tarCompression: $(tarCompression)
                  archiveExtension: $(archiveExtension)
                  artifactName: CheckedJIT_$(osGroup)$(osSubgroup)_$(archType)
                  displayName: JIT and SuperPMI Assets
            condition: not(eq(stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_jiteeversionguid.containsChange'], true))

      - template: /eng/pipelines/common/platform-matrix.yml
        parameters:
          jobTemplate: /eng/pipelines/coreclr/templates/superpmi-replay-job.yml
          buildConfig: checked
          platforms:
          - windows_x64
          - windows_x86
          helixQueueGroup: ci
          helixQueuesTemplate: /eng/pipelines/coreclr/templates/helix-queues-setup.yml
          jobParameters:
            condition: not(eq(stageDependencies.EvaluatePaths.evaluate_paths.outputs['SetPathVars_jiteeversionguid.containsChange'], true))
